home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1989 …il & Dave's Excellent CD / Excellent CD HFS.raw / Moof / Goodies / MPW Goodies / Interfaces / PInterfaces / CursorCtl.p < prev    next >
Encoding:
Text File  |  1988-11-30  |  5.6 KB  |  139 lines  |  [TEXT/MPS ]

  1. {
  2. Created: Tuesday, August 2, 1988 at 12:24 PM
  3.     CursorCtl.p
  4.     Pascal Interface to the Macintosh Libraries
  5.  
  6.     
  7.     <<< CursorCtl - Cursor Control Interface File >>>
  8.     
  9.     
  10.     Copyright Apple Computer, Inc. 1984-1988
  11.     All rights reserved
  12.     
  13.     This file contains:
  14.     
  15.     InitCursorCtl(newCursors) - Init CursorCtl to load the 'acur' resource
  16.     RotateCursor(counter) - Sequence through cursor frames for counter mod 32
  17.     SpinCursor(increment) - Sequence mod 32 incrementing internal counter
  18.     Hide_Cursor() - Hide the current cursor
  19.     Show_Cursor(cursorKind) - Show the cursor
  20. }
  21.  
  22.  
  23. {$IFC UNDEFINED UsingIncludes}
  24. {$SETC UsingIncludes := 0}
  25. {$ENDC}
  26.  
  27. {$IFC NOT UsingIncludes}
  28.     UNIT CursorCtl;
  29.     INTERFACE
  30. {$ENDC}
  31.  
  32. {$IFC UNDEFINED UsingCursorCtl}
  33. {$SETC UsingCursorCtl := 1}
  34.  
  35.  
  36. TYPE
  37.  
  38. { Kinds of cursor supported by CursorCtl }
  39. Cursors = (HIDDEN_CURSOR,I_BEAM_CURSOR,CROSS_CURSOR,PLUS_CURSOR,WATCH_CURSOR,
  40.     ARROW_CURSOR);
  41.  
  42. acurPtr = ^Acur;
  43. acurHandle = ^acurPtr;
  44. Acur = RECORD
  45.     n: INTEGER;         {Number of cursors ("frames of film")}
  46.     index: INTEGER;     { Next frame to show <for internal use>}
  47.     frame1: INTEGER;    {'CURS' resource id for frame #1}
  48.     fill1: INTEGER;     {<for internal use>}
  49.     frame2: INTEGER;    {'CURS' resource id for frame #2}
  50.     fill2: INTEGER;     {<for internal use>}
  51.     frameN: INTEGER;    {'CURS' resource id for frame #N}
  52.     fillN: INTEGER;     {<for internal use>}
  53.     END;
  54.  
  55.  
  56.  
  57. PROCEDURE InitCursorCtl(newCursors: UNIV acurHandle);
  58. { Initialize the CursorCtl unit. This should be called once prior to calling
  59. RotateCursor or SpinCursor. It need not be called if only Hide_Cursor or
  60. Show_Cursor are used. If NewCursors is NULL, InitCursorCtl loads in the
  61. 'acur' resource and the 'CURS' resources specified by the 'acur' resource
  62. ids.  If any of the resources cannot be loaded, the cursor will not be
  63. changed.
  64.  
  65. The 'acur' resource is assumed to either be in the currently running tool or
  66. application, or the MPW Shell for a tool, or in the System file.  The 'acur'
  67. resource id must be 0 for a tool or application, 1 for the Shell, and 2 for
  68. the System file.
  69.  
  70. If NewCursors is not NULL, it is ASSUMED to be a handle to an 'acur' formatted
  71. resource designated by the caller and it will be used instead of doing a
  72. GetResource on 'acur'. Note, if RotateCursor or SpinCursor are called without
  73. calling InitCursorCtl, then RotateCursor and SpinCursor will do the call for
  74. the user the first time it is called.  However, the possible disadvantage of
  75. using this technique is that the resource memory allocated may have
  76. undesirable affect (fragmentation?) on the application. Using InitCursorCtl
  77. has the advantage of causing the allocation at a specific time determined by
  78. the user.
  79.  
  80. Caution: InitCursorCtl MODIFIES the 'acur' resource in memory.  Specifically,
  81. it changes each FrameN/fillN integer pair to a handle to the corresponding
  82. 'CURS' resource also in memory.  Thus if NewCursors is not NULL when
  83. InitCursorCtl is called, the caller must guarantee NewCursors always points to
  84. a "fresh" copy of an 'acur' resource.  This need only be of concern to a
  85. caller who wants to repeatly use multiple 'acur' resources during execution of
  86. their programs.
  87.  }
  88.  
  89. PROCEDURE RotateCursor(counter: LONGINT);
  90. { RotateCursor is called to rotate the "I am active" "beach ball" cursor, or to
  91. animate whatever sequence of cursors set up by InitCursorCtl. The next cursor
  92. ("frame") is used when Counter % 32 = 0 (Counter is some kind of incrementing
  93. or decrementing index maintained by the caller). A positive counter sequences
  94. forward through the cursors (e.g., it rotates the "beach ball" cursor
  95. clockwise), and a negative cursor sequences through the cursors backwards
  96. (e.g., it rotates the "beach ball" cursor counterclockwise).  Note,
  97. RotateCursor just does a Mac SetCursor call for the proper cursor picture.
  98.   It is assumed the cursor is visible from a prior Show_Cursor call.
  99.  }
  100.  
  101. PROCEDURE SpinCursor(increment: INTEGER);
  102. { SpinCursor is similar in function to RotateCursor, except that instead of
  103. passing a counter, an Increment is passed an added to a counter maintained
  104. here.  SpinCursor is provided for those users who do not happen to have a
  105. convenient counter handy but still want to use the spinning "beach ball"
  106. cursor, or any sequence of cursors set up by InitCursorCtl.  A positive 
  107. increment sequences forward through the curos (rotating the "beach ball"
  108. cursor clockwise), and a negative increment sequences backward through the
  109. cursors (rotating the "beach ball" cursor counter-clockwise).  A zero value
  110. for the increment resets the counter to zero.  Note, it is the increment, and
  111. not the value of the counter that determines the sequencing direction of the
  112. cursor (and hence the spin direction of the "beach ball" cursor).
  113.  }
  114.  
  115. PROCEDURE Hide_Cursor;
  116. { Hide the cursor if it is showing.This is this unit's call to the Mac
  117. HideCursor routine.Thus the Mac cursor level is decremented by one when this
  118. routine is called.
  119.  }
  120.  
  121. PROCEDURE Show_Cursor(cursorKind: Cursors);
  122. { Increment the cursor level, which may have been decremented by Hide_Cursor,
  123. and display the specified cursor if the level becomes 0 (it is never
  124. incremented beyond 0).The CursorKind is the kind of cursor to show.  It is
  125. one of the values HIDDEN_CURSOR, I_BEAM_CURSOR, CROSS_CURSOR, PLUS_CURSOR,
  126. WATCH_CURSOR, and ARROW_CURSOR. Except for HIDDEN_CURSOR, a Mac SetCursor is 
  127. done for the specified cursor prior to doing a ShowCursor.  HIDDEN_CURSOR just
  128. causes a ShowCursor call.  Note, ARROW_CURSOR will only work correctly if
  129. there is already a grafPort set up pointed to by 0(A5).
  130.  }
  131.  
  132.  
  133. {$ENDC}    { UsingCursorCtl }
  134.  
  135. {$IFC NOT UsingIncludes}
  136.     END.
  137. {$ENDC}
  138.  
  139.